package huoye.shops.huoye.mine.adapter;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.codeideology.android.widget.recycler.RecyclerViewAdapter;

import butterknife.BindView;
import huoye.shops.R;
import huoye.shops.huoye.mine.model.DividendInfo;
import huoye.shops.huoye.operation.model.ManageEventData;
import huoye.shops.huoye.user.model.User;
import huoye.shops.widget.RoundImageView;


/**
 * Created by uesr on 2018/8/10.
 */

public class DividendAdapter extends RecyclerViewAdapter<DividendAdapter.ViewHolder,DividendInfo> {


    public DividendAdapter(Context context) {
        super(context, R.layout.item_dividend);
    }

    @Override
    protected ViewHolder initViewHolder(View view, int i) {

        return new ViewHolder(view);
    }

    @Override
    protected void bindView(ViewHolder holder, final DividendInfo data, int i) {

        holder.tvXs.setText(data.getOnlineMoney());
        holder.tvXx.setText(data.getOfflineMoney());
        holder.tvDividendMine.setText(data.getShareRatio()+"%");
        holder.tvDividendMoney.setText(data.getAllotMoney());

        String s = addSpace(data.getYearMonth());

        holder.tvTime.setText(s);

    }
    private String addSpace(String str) {
        if (str == null){
            return "";
        }
        char[] strs=str.toCharArray();
        StringBuilder sb=new StringBuilder();
        for (int i = 0; i < strs.length; i++) {
            sb.append(strs[i]);
            if (i!=0&&(i+1)%4==0){
                sb.append("-");
            }
        }
        String trim = sb.toString().trim();
        return trim;
    }




    public class ViewHolder extends RecyclerViewAdapter.ViewHolder {

        @BindView(R.id.item_dividend_tv_turnover_xs)
        TextView tvXs;
        @BindView(R.id.item_dividend_tv_turnover_xx)
        TextView tvXx;
        @BindView(R.id.item_dividend_tv_dividend_mine)
        TextView tvDividendMine;
        @BindView(R.id.item_dividend_tv_dividend_money)
        TextView tvDividendMoney;
        @BindView(R.id.item_dividend_tv_time)
        TextView tvTime;





        public ViewHolder(View itemView) {
            super(itemView);
        }
    }



    public void setOnManageAccountDataListener(OnManageAccountListener onManageAccountListener) {
        this.listener = onManageAccountListener;
    }

    private OnManageAccountListener listener;

    public interface OnManageAccountListener {

        void onDeleteClick();
        void onEditClick();


    }

}
